package com.itheima.web.response;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * 响应字符数据：设置字符数据的响应体
 */
@WebServlet("/resp3")
public class ResponseDemo3 extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        response.setContentType("text/html;charset=utf-8"); //设置响应的字符数据，注意用分号间隔，要写在流的编码，因为是设置了流的编码
        //1.获取字符输出流
        //设置响应头信息 content-type
//        response.setHeader("content-type","text/html");
        PrintWriter writer = response.getWriter();

        writer.write("你好");
        writer.write("<h1>aaaa</h1>");
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doGet(request, response);
    }
}